package com.xuecheng.system.controller;

import com.xuecheng.commons.model.dto.LoginDto;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Sober_wxy
 * @date 2022/7/15 17:29
 * 用户登录 请求参数 dto 响应 vo
 */
@RestController
public class LoginController {
        @Autowired
        private UserService userService;

        /**
         * 登录
         * @param loginDto 封装 username password utype
         * @return loginVo 封装 code errorMessage data { token , username }
         */
        @PostMapping("/login")
        public ResponseResult login(@RequestBody LoginDto loginDto){
                return userService.login(loginDto);
        }
}
